package com.turbo.cloud.contract.web.webservice;

import com.turbo.cloud.contract.web.logic.OverlayLogic;
import com.turbo.cloud.contract.web.model.overlay.CtContractTemplateOverlayQO;
import com.turbo.cloud.contract.web.model.overlay.CtContractTemplateOverlayDO;
import com.turbo.cloud.contract.web.model.overlay.CtContractTemplateOverlayVO;
import com.turbo.cloud.core.api.R;
import com.turbo.cloud.core.api.Result;
import com.turbo.cloud.core.validated.InsertValidated;
import com.turbo.cloud.core.validated.SelectListValidated;
import com.turbo.cloud.core.validated.UpdateValidated;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 合同模板覆盖物表 前端控制器
 * </p>
 *
 * @author zhangluning
 * @since 2023-11-23
 */
@Slf4j
@RequiredArgsConstructor
@RestController
public class CtContractTemplateOverlayController {

    final OverlayLogic overlayLogic;

    /**
     * 查询合同模板表单列表
     *
     * @param ctContractTemplateOverlayQO 查询实体
     * @return Page
     */
    @PostMapping(name = "查询合同模板表单列表", value = "/webservice/overlay/queryOverlayListByContractTemplateId")
    public Result<List<CtContractTemplateOverlayVO>> queryOverlayListByContractTemplateId(@RequestBody @Validated(SelectListValidated.class) CtContractTemplateOverlayQO ctContractTemplateOverlayQO) {
        List<CtContractTemplateOverlayVO> result = overlayLogic.queryOverlayListByContractTemplateId(ctContractTemplateOverlayQO);
        return R.result(result);
    }

    /**
     * 新增合同模板
     *
     * @param ctContractTemplateOverlayDO 实体
     * @return
     */
    @PostMapping(name = "新增合同模板", value = "/webservice/overlay/createContractTemplateOverlay")
    public Result<Boolean> createContractTemplateOverlay(@RequestBody @Validated(InsertValidated.class) CtContractTemplateOverlayDO ctContractTemplateOverlayDO) {
        boolean result = overlayLogic.createContractTemplateOverlay(ctContractTemplateOverlayDO);
        return R.result(result);
    }

    /**
     * 修改合同模板
     *
     * @param ctContractTemplateOverlayDO 实体
     * @return
     */
    @PostMapping(name = "修改合同模板", value = "/webservice/overlay/modifyContractTemplateOverlay")
    public Result<Boolean> modifyContractTemplateOverlay(@RequestBody @Validated(UpdateValidated.class) CtContractTemplateOverlayDO ctContractTemplateOverlayDO) {
        boolean result = overlayLogic.modifyContractTemplateOverlay(ctContractTemplateOverlayDO);
        return R.result(result);
    }
}
